package com.example.lwj.application;

import android.app.Application;
import android.content.Context;
import android.os.Handler;
import android.os.Process;

import org.xutils.x;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * Created by lwj on 2016/10/31.
 */
public class MyAplication extends Application {

    private static Context context;
    private static Handler handler;
    private static int mainThreadId;
    private static Thread mainThread;
    private static ExecutorService pool;

    @Override
    public void onCreate() {
        super.onCreate();
        context = getApplicationContext();
        handler = new Handler();
        //找一个工具类 无论怎么走都会走到主线程中
        //拿到主线程的id
        mainThreadId = Process.myTid();
        //拿到主线程
        mainThread = Thread.currentThread();
        //准备线程池
        pool = Executors.newFixedThreadPool(5);
        //配置Utils
        x.Ext.init(this);
        //打Log的功能
        x.Ext.setDebug(true);
    }

    public static Context getContext() {
        return context;
    }

    public static Handler getHandler() {
        return handler;
    }

    public static int getMainThreadId() {
        return mainThreadId;
    }

    public static Thread getMainThread() {
        return mainThread;
    }
    public static ExecutorService getPool(){
        return pool;
    }
}
